package com.asset.salesforce.converter;

import com.asset.salesforce.domain.Call;
import com.asset.salesforce.form.CallForm;

public class CallConverter {


public CallForm ConvertCall(Call call){
		CallForm callForm = new CallForm();
			if(call.getCrmStaff().getId()!=null){
				callForm.setCrmStaff(call.getCrmStaff().getId());
			}
			if(call.getContactedPerson().getId()!=null){
				callForm.setContactedPerson(call.getContactedPerson().getId());
			}
			if(call.getDate()!=null){
				String dateSubstring = call.getDate().toString().substring(0, 10);
				String[] dateSplit = dateSubstring.split("-");
				
				String dateFinal = dateSplit[2]+"/" +dateSplit[1]+"/" +dateSplit[0];
				callForm.setDate(dateFinal);
			}
			if(call.getInOutCall()!=null){
				callForm.setInOutCall(call.getInOutCall().toString());
			}
			if(call.getDecisionMaker()!=null){
				callForm.setDecisionMaker(call.getDecisionMaker().toString());
			}
			
			if(call.getComment()!=null){
				callForm.setComment(call.getComment());
			}
			if(call.getNextFollowUp()!=null){
				callForm.setNextFollowUp(call.getNextFollowUp().toString());
			}
			
			if(call.getFollowUpType()!=null){
				callForm.setNextFollowUpType(call.getFollowUpType());
			}
			
			if(call.getFollowUpDate()!=null){
				String followUpDateSubstring = call.getFollowUpDate().toString().substring(0, 10);
				String[] followUpDateSplit = followUpDateSubstring.split("-");
				String followUpDateFinal = followUpDateSplit[2]+"/" +followUpDateSplit[1]+"/" +followUpDateSplit[0];
				callForm.setNextFollowUpDate(followUpDateFinal);
			}
			
			if(call.getFollowUpDetails()!=null){
				callForm.setNextFollowUpDetails(call.getFollowUpDetails());
			}
			if(call.getParentId()!=null){
				callForm.setParentId(call.getParentId());
			}
			if(call.getStartTime()!=null&&!call.getStartTime().equalsIgnoreCase("")){
				callForm.setStartTime(call.getStartTime());
			}
			if(call.getEndTime()!=null&&!call.getEndTime().equalsIgnoreCase("")){
				callForm.setEndTime(call.getEndTime());
			}
			
		return callForm;
	}
}
